{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerheader.html"}
{literal}
<script>
    function keyLogin(){
        if (event.keyCode==13)//按Enter键的键值为13
            document.getElementById("loginin").click();//调用登录按钮的登录事件
    }
function change_code(){
        var img = document.getElementById('login_code_img');
        img.src = '/login/code/rand/' + Math.random();
    };

    $(function(){
        $(".lcl_btn").click(function(){
            var username =  $("input[name=username]").val();
            var password =  $("input[name=password]").val();
            var code =  $("input[name=code]").val();
            var back_url = $('input[name=back_url]').val();
            $.ajax({
                url:'/login/login',
                data:{username:username,password:password,code:code,back_url:back_url},
                type:'POST',
                success:function(data){
                    var data = eval("("+data+")");
                    var code = data.code;
                    var back_url = data.back_url;
                    if(code == 1004){
                        alert(data.msg);
                        change_code();
                        return;
                    }
                    if(code == 1008){
                        if(back_url != ''){
                            window.location.href=back_url;
                        }else{
                            window.location.href = "/user";
                        }
                    }else{
                        alert(data.msg);
                        return;
                    }
                    return false;
                },
                dataType:'text'
            });
        });
    });
</script>
{/literal}
<div class="clearfix"></div>

<div class="login_wrap">
	<div class="login">
    	<div class="login_media_img">
        	<img src="images/login_fb.jpg" width="630" height="350"/>
        </div>
        
        <div class="login_content" onkeydown="keyLogin();">
        	<div class="login_text">
        	<h3 class="fs16">会员登录<a href="/register" class="login_text_reg blue"><i></i><span class="fl">立即注册</span></a></h3>
            <ul class="login_ct_list">
            	<li><input class="lcl_text" type="text" name="username" placeholder="请输入手机号码" /></li>
                <li><input class="lcl_text" type="password" name="password" placeholder="请输入密码" /><input type="hidden" name="back_url" value="{$back_url}"/></li>
                <li><input class="lcl_text wid18 fl" type="text" name="code" placeholder="请输入验证码"/>
                <img src="/login/code" class="ml10 cp" id="login_code_img" onclick="change_code()" width="135" height="36"  />
                <li><a href="/findpwd/index" class="fr">忘记密码？</a></li>
                <li><input id="loginin" class="lcl_btn" type="button" value="登    录"/></li>
                <!--<li class="third_party"><div><i>第三方账号登录</i></div></li>-->
                <!--<li class="tac pt20"><a href="/login/qqlogin"><img class="ml5" alt="QQ登录" src="images/login_qq.jpg"></a><a href="/login/sinalogin"><img class="ml10" src="images/sian.jpg"></a></li>-->
            </ul>
            </div>
            <!--<div class="login_agreement fs12"><label><input name="" checked="checked" type="checkbox" value="" class="check_box mr5"/>已阅读并同意<a href="#" class="blue">《塑料交易网用户服务协议》</a></label></div>-->
        </div>
        
    </div>
</div>


{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerfooter.html"}
